-- example: type class (overloading) --
library ieee;
   use ieee.std_logic_1164.all;
package element_pack_typeclass is

type Element is class
   class attribute Value: integer;
   impure function get_value return integer;
   impure function equal(Other: Element'CLASS) return boolean;
end class Element;

type Element is class body
   impure function get_value return integer is
   begin
      return Value;
   end;

impure function equal(Other: Element'CLASS) return boolean is
   begin
      return (Value = Other.get_value); 
   end;
end class body Element;

base class

type Child_Of_Element is new class Element with
   impure function equal return boolean;
   impure function equal (Other: Element'CLASS) return boolean;
end class Child_Of_Element;

type Child_Of_Element is class body

   impure function equal return boolean is
   -- overloads former method "equal"
   begin
      return (Value1=5);
   end;

   impure function equal(Other: Element'CLASS) return boolean is
   -- redefines former method "equal"   
   begin
      return (Value = Other.get_value + 5);
   end;

end class body Child_Of_Element;
end package;
derived classes